package com.atstudying.mall.mallcart.config;

import com.atstudying.mall.mallcart.interceptor.CartInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author Mr.zhneg
 * @create 2020-11-11-19:47
 */
@Configuration
public class MallWebConfig implements WebMvcConfigurer{

    /**
     * 添加一个拦截器，拦截器才可以工作
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有的请求/**
        registry.addInterceptor(new CartInterceptor()).addPathPatterns("/**");
    }

}
